package io.hxci.modules.edu.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hxci.common.annotation.SysLog;
import io.hxci.common.utils.PageUtils;
import io.hxci.common.utils.R;
import io.hxci.modules.edu.domain.EduCourse;
import io.hxci.modules.edu.domain.EduRecord;
import io.hxci.modules.edu.domain.EduSign;
import io.hxci.modules.edu.service.EduCourseService;
import io.hxci.modules.edu.service.EduRecordService;
import io.hxci.modules.sys.controller.AbstractController;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;
import java.util.stream.Collectors;

@RestController
@RequestMapping("edu/coursing")
public class EduCoursingController extends AbstractController {
    @Autowired
    private EduCourseService eduCourseService;
    @Autowired
    private EduRecordService eduRecordService;
    @Autowired
    private EduRecordService EduRecordStuService;

    @SysLog("查看课程信息")
    @RequestMapping("/query")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = eduCourseService.queryPageInfo(params,getUserId());
        return R.ok().put("page", page);
    }
    @RequestMapping("/check")
    public  R check(String recordid){

        List<EduSign> list =eduCourseService.check(recordid);
//        List<EduSign> unique = list.stream().collect(Collectors.collectingAndThen(
//                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(EduSign::getSname))), ArrayList::new));

       // int a =eduCourseService.count(eduSign);.put("sd", a)
        return R.ok().put("list", list);
    }
//    @RequestMapping("/change")
//    public  String change(EduSign eduSign){
//        eduCourseService.change(eduSign);
//        return "1";
//    }


    @RequestMapping("/batchAdd")
    public  R batchAdd(EduRecord eduRecord,@RequestParam(value = "bjs[]") Long[] bjs){
        String a =eduRecordService.batchAdd(eduRecord,bjs);

        return R.ok().put("ids", a).put("timer", System.currentTimeMillis());
    }


}
